
<!-- Page statistics and control buttons area -->
    <div class="statsRow">
        <div class="wrapper statsItems">
			
            <!-- Stats item -->
            <div class="sItem ticketsStats">
                <h2><a title="" class="value">
                    <?php 
                        if (!empty($this->campaigns)) {
                         echo count($this->campaigns);   
                        }
                    ?><span>Campaigns</span></a></h2>
                <div class="statsDetailed" id="s1">
                    <div class="statsContent">
                        <div class="sElements">
                            <div class="sDisplay"><h4>100</h4><span>active</span></div>
                            <div class="sDisplay"><h4>75</h4><span>stopped</span></div>
                            <div class="sDisplay"><h4>25</h4><span>blocked</span></div>
                        </div>
                        <span class="line"></span>
                        <div class="statsUpdate">
                            <span>Next update in:</span>
                            <span>19 hrs 49 min</span>
                            <div class="contentProgress"><div class="barG tipS" title="19%" id="bar1"></div></div>
                        </div>
                        <div class="statsDropBtn"><a href="#" class="button basic"><img src="/images/icons/dark/stats.png" class="icon" alt="" /><span>View statistics</span></a></div>
                    </div>
                </div>
                <span class="changes">
                    <span class="negBar" values="5,10,15,20,18,16,14,20,15,16"></span>
                    <span class="negative">+0.6%</span>
                </span>
            </div>
			
			<div class="sItem ticketsStats">
                <h2><a title="" class="value">2000<span>Advertisements</span></a></h2>
                <div class="statsDetailed" id="s1" style="width:300px">
                    <div class="statsContent">
                        <div class="sElements">
                            <div class="sDisplay"><h4>1000</h4><span>context</span></div>
                            <div class="sDisplay"><h4>750</h4><span>banners</span></div>
                            <div class="sDisplay"><h4>150</h4><span>microblogs</span></div>
							<div class="sDisplay"><h4>100</h4><span>social</span></div>
                        </div>
                        <span class="line"></span>
                        <div class="statsUpdate">
                            <span>Next update in:</span>
                            <span>19 hrs 49 min</span>
                            <div class="contentProgress"><div class="barG tipS" title="19%" id="bar1"></div></div>
                        </div>
                        <div class="statsDropBtn"><a href="#" class="button basic"><img src="/images/icons/dark/stats.png" class="icon" alt="" /><span>View statistics</span></a></div>
                    </div>
                </div>
                <span class="changes">
                    <span class="negBar" values="5,10,15,20,18,16,14,20,15,16"></span>
                    <span class="negative">+0.6%</span>
                </span>
            </div>
			
			<!-- Stats item -->
            <div class="sItem usersStats">
                <h2><a title="" class="value">548463$<span>Advertiser's payments</span></a></h2>
                <div class="statsDetailed" id="s3">
                    <div class="statsContent">
                        <div class="sElements">
                            <div class="sDisplay"><h4>548463$</h4><span>last month</span></div>
                            <div class="sDisplay"><h4>36422$</h4><span>reserved for campaigns</span></div>
                            <div class="sDisplay"><h4>5373$</h4><span>payed today</span></div>
                        </div>
                        <span class="line"></span>
                        <div class="statsUpdate">
                            <span>Next update in:</span>
                            <span>10 hrs 55 min</span>
                            <div class="contentProgress"><div class="barG tipS" id="bar3" title="32%"></div></div>
                        </div>
                        <div class="statsDropBtn"><a href="#" class="button basic"><img src="/images/icons/dark/users.png" class="icon" alt="" /><span>View advertisers</span></a></div>
                    </div>
                </div>
                <span class="changes">
                    <span class="zeroBar" values="5,10,15,20,25,30,35,40,45,50"></span>
                    <span class="zero">0.0%</span>
                </span>
            </div>
			
        </div>
    </div>
	<div class="line"></div>

    <!-- Main content wrapper -->
    <div class="wrapper">
    
        <!-- Dynamic table -->
        <div class="widget">
            <div class="title"><img src="/images/icons/dark/full2.png" alt="" class="titleIcon" /><h6>Ваши кампании</h6></div>
            <table cellpadding="0" cellspacing="0" border="0" class="display dTable">
            <thead>
            <tr>
            <th>Название</th>
            <th>Количество рекламы</th>
            <th>Мини сайт</th>
			<th>Дата начала</th>
            <th>Дата окончания</th>
			<th>Тематика</th>
			<th>Бюджет</th>
			<th>Затраты</th>
            <th>Статус</th>
            <th>Действия</th>
            </tr>
            </thead>
            <tbody>
            <?php
            if (!empty($this->campaigns)) {
            foreach ($this->campaigns as $comp) {
                if ($comp['id_status'] == 1) {
                    echo '<tr class="gradeA">';
                }
                elseif ($comp['id_status'] == 2) {
                    echo '<tr class="gradeC">';
                }
                elseif ($comp['id_status'] == 3) {
                    echo '<tr class="gradeX">';
                }
                else {
                    echo '<tr class="gradeA">';
                }
                    echo '<td>'.$comp['name'].'</td>';
                    
                    echo '<td>'.$comp['count'].'</td>';
                                            
                    echo '<td class="center">есть</td>';
			echo '<td class="center">'.date("d-m-Y",strtotime($comp['date_start'])).'</td>';
			echo '<td class="center">'.date("d-m-Y",strtotime($comp['date_end'])).'</td>';
			echo '<td class="center">'.$comp['cat_name'].'</td>';
			echo '<td class="center">'.$comp['start_budget'].'$</td>';
                        if ($comp['start_budget'] >= $comp['current_budget']){
                            echo '<td class="center">'.($comp['start_budget'] - $comp['current_budget']).'$</td>';
                        } else {
                            echo '<td class="center">превышен лимит</td>';
                        }
			echo '<td class="center">'.$comp['status'].'</td>';
			echo '<td class="center"><a href="#">statistics</a>';
                        if ($comp['id_status'] == 3){
                        echo '<a class="button greenB" href="'.$this->url(array(
                                                'module'     => 'adv',
                                                'controller' => 'campaigns',
                                                'action'     => 'activatecampaign',
                                                'id'         => $comp['id']
                                      )).'">'.$this->translate('Activate').'</a>';
                        }
                        elseif ($comp['id_status'] == 1) {
                        echo '<a class="button redB" href="'.$this->url(array(
                                                'module'     => 'adv',
                                                'controller' => 'campaigns',
                                                'action'     => 'deactivatecampaign',
                                                'id'         => $comp['id']
                                      )).'">'.$this->translate('deactivate').'</a>';
                        }
                        echo '<a href="#">edit</a>'; 
                        echo '<a class="button redB" href="'.$this->url(array(
                                                'module'     => 'adv',
                                                'controller' => 'campaigns',
                                                'action'     => 'deletecampaign',
                                                'id'         => $comp['id']
                                      )).'">'.$this->translate('delete').'</a>';
            echo '</tr>';
            }
            }
            ?>
            </tbody>
            </table>
			
        </div>
		
				<div class="loginControl" style="width: 260px; float:right;">
                                  
                                <?php echo '<a class="button greenB" href="'.$this->url(array(
                                                'module'     => 'adv',
                                                'controller' => 'campaigns',
                                                'action'     => 'newcampaignfirst'
                                      )).'"><span>'.$this->translate('Сгенерировать новую кампанию').'</span></a>';?>
				 <div class="clear"></div>
                </div>
				
    </div>